package com.bdqn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.pojo.SysUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * SysUserMapper
 *
 * @author LILIBO
 * @since 2025/3/17
 */
public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 根据姓名和角色ID查找用户列表（自定义接口）
     *
     * @return
     */
    /*
    @Select("<script>" +
            "select * from sys_user" +
            "<where>" +
            "            <if test=\"usrName != null and usrName != ''\">" +
            "                AND `usr_name` like CONCAT('%', #{usrName}, '%')" +
            "            </if>" +
            "            <if test=\"usrRoleId != null and usrRoleId != 0\">" +
            "                AND `usr_role_id` = #{usrRoleId}" +
            "            </if>" +
            "        </where>" +
            "</script>")
    */
    List<SysUser> getByUsrNameAndRoleId(@Param("usrName") String usrName, @Param("usrRoleId") Long usrRoleId);

    /**
     * 根据姓名和密码查找用户列表（自定义接口）
     *
     * @return
     */
    @Select("select * from sys_user where usr_name=#{usrName} and usr_password=#{usrPassword} limit 1")
    SysUser getByUsrNameAndUsrPassword(@Param("usrName") String usrName, @Param("usrPassword") String usrPassword);

    /**
     * 分页查询
     *
     * @param usrName
     * @param usrRoleId
     * @param page 分页对象
     * @return
     */
    Page<SysUser> pageByUsrNameAndRoleId(@Param("usrName") String usrName, @Param("usrRoleId") Long usrRoleId, Page<SysUser> page);

}
